package com.rave.announcementview;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewSwitcher;

import com.rave.announcementview.view.AnnouncementView;
import com.rave.announcementview.view.IMarqueeItem;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    AnnouncementView announcementView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        announcementView = findViewById(R.id.textSwitcher);

        List<TestBean> beans = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            beans.add(new TestBean("test:" + i));
        }

        announcementView.setMarqueeItems(beans);
        announcementView.setOnItemClickListener(new AnnouncementView.OnItemClickListener() {
            @Override
            public void onItemClick(int position, IMarqueeItem marqueeItem) {
                Toast.makeText(MainActivity.this, marqueeItem.getMarqueeDisplayText(), Toast.LENGTH_LONG).show();
            }
        });

    }
}
